package com.team2.s3hrjyxm.qxglcontroller;

import java.beans.PropertyEditor;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

public class BaseController {
	PrintWriter out;
	//表示调用controller方法之前会执行
	@ModelAttribute 
	public void up(HttpServletResponse response) throws IOException{
		response.setCharacterEncoding("UTF-8");
		out = response.getWriter();
	}
	
//时间类型转换器
	@InitBinder
	public void convertDate(WebDataBinder bind){
		DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); 
		PropertyEditor n=new CustomDateEditor(format, true);
		bind.registerCustomEditor(Date.class, n);
		
	}
	
}
